import { HttpSrv } from 'lfun-bg-comp';

export interface PageParams {
  page?: number;
  per_page?: number;
}

export interface Result<T> {
  errorCode: number;
  data: T;
  message: string;
  details: string;
  success: boolean;
}

export interface PageResult<T> {
  has_next: boolean;
  has_prev: boolean;
  items: Array<T>;
  page: number;
  pages: number;
  per_page: number;
  total: number;
}
export interface MenuParams {
  system_type: 'unit' | 'teacher' | 'student' | 'mg';
  edu_type: 'kg' | 'k12' | 'vocational' | 'institute' | 'administration';
  unit_type: 'city' | 'county' | 'school' | any;
  school_id?: string;
  county_id?: string;
  user_name?: string;
  account_id?: string;
  phone?: string;
}

export interface ImportParams {
  file_name: string;
  bucket_name: string;
  scene:
    | 'new_teachers'
    | 'teachers_basic'
    | 'teachers_shortcut'
    | 'teachers_extend'
    | 'planning_school'
    | 'school'
    | 'institution'
    | 'new_student'
    | 'class';
}

// 获取省
export const getProvince = () =>
  HttpSrv().get('/school/v1/enums/page', { params: { enum_name: 'province', page: 1, per_page: 1000 } });
// 获取省市
export const getCity = (parent_code?: string) =>
  HttpSrv().get('/school/v1/enums/page', {
    params: { parent_code, enum_name: 'city', page: 1, per_page: 1000 },
  });
// 获取区
export const getCountry = (parent_code: string) =>
  HttpSrv().get('/school/v1/enums/page', { params: { parent_code, enum_name: 'country', page: 1, per_page: 1000 } });

// 省市
export const getProvinceCity = () =>
  HttpSrv().get('/school/v1/enums/page', { params: { enum_name: 'province,city', page: 1, per_page: 1000 } });

// 菜单列表
export const getMenu = (params: MenuParams) => HttpSrv().get('/school/v1/system/menu', { params });

export const getWorkFlowStatus = (process_instance_id: any) =>
  HttpSrv().get('/school/v1/system/work-flow-status', { params: { process_instance_id } });

export const getWorkFlowSNodeLogs = (process_instance_id: any) =>
  HttpSrv().get('/school/v1/system/work-flow-node-log', { params: { process_instance_id } });
export const getWorkFlowDefine = (process_instance_id: any) =>
  HttpSrv().get('/school/v1/system/work-flow-define', { params: { process_instance_id } });
